package top.retain;

import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.locks.LockSupport;
import sun.misc.Unsafe;

/**
 * @author ivorfan
 * @date 2021/7/24 15:42
 */
public class FanxingTest {

    public static void main(String[] args)
            throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
        FutureTask<String> task = new FutureTask<String>(() -> {
            System.out.println("aaaa");
            return "saaa";
        });
        Thread t1 = new Thread(task);
        t1.join();
        t1.interrupt();
        t1.start();
        System.out.println(t1.isInterrupted());
        System.out.println(Thread.interrupted());
        Thread.currentThread().interrupt();
        System.out.println(Thread.interrupted());
        System.out.println(task.get());
        Unsafe unsafe = Unsafe.getUnsafe();
        unsafe.loadFence();
        LockSupport.park();
    }

}
